CXX = mpic++
CPPFLAGS += -g -DUSE_QSIM -DKERNEL_UTEST -DNO_MPI -I/usr/include/cppunit -I../.. -I../../../../.. -I../../../../../models/cache -I/home/jwang/workspace/qsim/installdir/include
LDFLAGS += -lcppunit -lqsim
EXECS = simple_procTest

VPATH = ../.. ../../../../../kernel ../../../../../models/cache/simple-cache

# If the kernel directory already has an object, say clock.o, then the object is
# not built. This may be wrong. So we use different names for kernel objects. This
# way the objects in the kernel directory are not picked up.
KERNEL_OBJS = kernel-clock.o kernel-component.o kernel-manifold.o kernel-messenger.o

# Do the same for simple-proc
SIMPLE_PROC_OBJS = SimpleProc-simple-proc.o SimpleProc-instruction.o

SIMPLE_CACHE_OBJS = SimpleCache-cache_messages.o



ALL: $(EXECS)

simple_procTest: simple_procTest.o $(SIMPLE_PROC_OBJS) $(KERNEL_OBJS) $(SIMPLE_CACHE_OBJS)
	$(CXX) -o$@ $^ $(LDFLAGS)



kernel-%.o: %.cc
	@[ -d dep ] || mkdir dep
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF dep/$*.d -c $< -o kernel-$*.o

SimpleProc-%.o: %.cc
	@[ -d dep ] || mkdir dep
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF dep/$*.d -c $< -o SimpleProc-$*.o

SimpleCache-%.o: %.cpp
	@[ -d dep ] || mkdir dep
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF dep/$*.d -c $< -o SimpleCache-$*.o

%.o: %.cc
	@[ -d dep ] || mkdir dep
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF dep/$*.d -c $< -o $*.o

%.o: %.cpp
	@[ -d dep ] || mkdir dep
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF dep/$*.d -c $< -o $*.o

-include $(wildcard dep/*.d)

.PHONY: clean
clean:
	rm -f $(EXECS) *.o DBG*
	rm -rf dep
